package com.eascs.admin.recordlog.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.eascs.admin.common.controller.BaseViewController;
import com.eascs.admin.recordlog.servcie.O2oRecordLogService;
import com.eascs.admin.recordlog.vo.O2oRecordLogVo;
import com.eascs.app.dao.PageResult;
import com.eascs.common.util.UrlUtil;
import com.eascs.site.page.PaginationInfo;
import com.eascs.site.page.SelectDataOption;
import com.eascs.site.view.ViewContext;

/**
 * @ClassName: O2oRecordLogController.java
 * @Description:
 * 				<p>
 *               日志Controller
 *               </p>
 * @author CXW
 * @date 2016年9月22日 下午4:41:04
 * @version V1.0
 */
@Controller
@RequestMapping("/log")
public class O2oRecordLogController extends BaseViewController {

	@Autowired
	O2oRecordLogService recordService;

	@SuppressWarnings("unused")
	@RequestMapping("/index")
	public String index(O2oRecordLogVo vo) {
		vo.setPageSize(10);
		String url = "/log/index";
		if (null != vo) {
			String operUserName = vo.getOperUserName() == null ? "" : vo.getOperUserName();
			String logType = vo.getLogType() == null ? "" : vo.getLogType();
			url = UrlUtil.appendUrl(url, "operUserName", operUserName);
			url = UrlUtil.appendUrl(url, "logType", logType);
			url = url + "&pageIndex=";
		} else {
			url = url + "&pageIndex=";
		}
		PageResult<Object[]> pageResult = recordService.findByPage(vo);
		String titles[] = { "编号", "操作人", "操作时间", "操作类型", "描述" };
		SelectDataOption[] selectDataOptions = { null, null, null, new SelectDataOption("LOGTYPE"), null };
		PaginationInfo paginationInfo = new PaginationInfo(pageResult, titles, url);
		paginationInfo.setSelectDataOptions(selectDataOptions);
		paginationInfo.setBuildPagingNavigation(true);
		paginationInfo.setFirstRenderColumnIndex(0);

		ViewContext.put("vo", vo);
		ViewContext.put("logPaginationInfo", paginationInfo);
		return "log/index";
	}
}
